<template>
	<view>
		<web-view :src="url"></web-view>
	</view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue';
const url = ref(null)
onLoad((val) => {
	console.log(val.url)
	// 自定义base64解码函数，替代atob
	function fromBase64(str) {
		const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
		let output = '';
		let i = 0;
		str = str.replace(/[^A-Za-z0-9\+\/\=]/g, '');
		
		while (i < str.length) {
			const enc1 = chars.indexOf(str.charAt(i++));
			const enc2 = chars.indexOf(str.charAt(i++));
			const enc3 = chars.indexOf(str.charAt(i++));
			const enc4 = chars.indexOf(str.charAt(i++));
			
			const chr1 = (enc1 << 2) | (enc2 >> 4);
			const chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			const chr3 = ((enc3 & 3) << 6) | enc4;
			
			output += String.fromCharCode(chr1);
			if (enc3 !== 64) output += String.fromCharCode(chr2);
			if (enc4 !== 64) output += String.fromCharCode(chr3);
		}
		
		return output;
	}
	if (val.url.indexOf('https://rarcfw.ruiyi.info:36014/web?url') == -1) {
		url.value = 'https://rarcfw.ruiyi.info:36014/web?url=' + fromBase64(val.url)
	} else {
		url.value = fromBase64(val.url)
	}
	console.log(url.value)
})
</script>

<style>
</style>